package yxy.game.pm2.module.chibi;

import java.util.Collection;

import yxy.cherry.data.bean.chibidate;
import yxy.game.pm2.bean.Currency;
import yxy.game.pm2.bean.currency.Currencies;
import yxy.game.pm2.bean.mq.CCReason;
import yxy.game.pm2.module.CurrencyHandle;
import yxy.game.pm2.module.battle.ISettlement;

public class SettlementChibi implements ISettlement {
	// bean===========================================================================

	private String playerCode;
	private Currencies rewards;
	private int dataId;

	public String getPlayerCode() {
		return playerCode;
	}

	public void setPlayerCode(String playerCode) {
		this.playerCode = playerCode;
	}

	public Currencies getRewards() {
		return rewards;
	}

	public void setRewards(Currencies rewards) {
		this.rewards = rewards;
	}

	public int getDataId() {
		return dataId;
	}

	public void setDataId(int dataId) {
		this.dataId = dataId;
	}

	// func===========================================================================

	@Override
	public void settle() {
		new CurrencyHandle().addCurrency(playerCode, CCReason.火烧赤壁, getRewards());
		new ChibiHandle().finish(getPlayerCode(), getDataId());
	}

	@Override
	public Collection<Currency> reward() {
		return getRewards();
	}

	static public SettlementChibi create(String playerCode, chibidate data) {
		SettlementChibi settlement = new SettlementChibi();
		try {
			settlement.setPlayerCode(playerCode);
			settlement.setDataId(data.getId());
			settlement.setRewards(new Currencies(Currency.create(data.getFirstrewardtype(), data.getFirstrewardid(), data.getFirstrewardnum())));

			return settlement;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
